// ml:run = $bin < input
#include <fstream>

int const inf = 1 << 28;
int w, h, tw, th;

int dis(int a, int b)
{
    if (a < b) return inf;
    if (a == b) return 0;
    if (a & 1) {
        if (b > a / 2) return 1;
        return dis(a / 2 + 1, b) + 1;
    } else {
        if (b >= a / 2) return 1;
        return dis(a / 2, b) + 1;
    }
}

int calc(int w, int h, int a, int b)
{
    return dis(w, a) + dis(h, b);
}

int main()
{
    std::ifstream fin{"folding.in"};
    std::ofstream fout{"folding.out"};
    fin >> w >> h >> tw >> th;
    auto ans = std::min(calc(w, h, tw, th), calc(w, h, th, tw));
    if (ans >= inf) ans = -1;
    fout << ans << "\n";
}

